home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #1 / Amiga Plus 1995 #1.iso / fish-disketten / fish_691-700 / d695 / icalc / scripts / gl.ic < prev    next >
Text File  |  1994-12-13  |  651b  |  32 lines

  1. # 10-pt Gauss-Legendre integration
  2. # This is an 'open' method, i.e. it doesn't evaluate the function at
  3. # the integration limits, so the function may be undefined there.
  4. # However, user should consider existence of integral in such a case.
  5. #
  6. # mws, February, 1992.
  7.  
  8. array glx[5] = {
  9.     .1488743389, .4333953941, .6794095682, .8650633666, .9739065285
  10. }
  11.  
  12. array glw[5] = {
  13.     .2955242247, .2692667193, .2190863625, .1494513491, .0666713443
  14. }
  15.  
  16. func gl(~f,a,b) = {
  17.     local xm, xr, ss, j, dx, tmp
  18.     xm = 0.5*(b+a)
  19.     xr = 0.5*(b-a)
  20.     ss = 0
  21.     for (j = 1; j <= 5; j += 1) {
  22.         dx = xr*glx[j]
  23.         x = xm+dx
  24.         tmp = f
  25.         x = xm-dx
  26.         tmp += f
  27.         ss += glw[j]*tmp
  28.     }
  29.     xr*ss
  30. }
  31.  
  32.